import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '标题',
    align: "center",
    dataIndex: 'title'
  },
  {
    title: '标题图',
    align: "center",
    dataIndex: 'pic',
    customRender: render.renderImage,
  },
  {
    title: '排序',
    align: "center",
    dataIndex: 'sort'
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '更新时间',
    align: "center",
    dataIndex: 'updateTime'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
  {
    title: '点击前往资讯页',
    align: "center",
    dataIndex: 'toInformation_dictText'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '标题',
    field: 'title',
    component: 'Input',
  },
  {
    label: '标题图',
    field: 'pic',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入标题图!' },
      ];
    },
  },
  {
    label: '排序',
    field: 'sort',
    component: 'InputNumber',
  },
  {
    label: '点击前往资讯页',
    field: 'toInformation',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "nurse_information,title,code"
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  title: { title: '标题', order: 0, view: 'text', type: 'string' },
  pic: { title: '标题图', order: 1, view: 'image', type: 'string' },
  sort: { title: '排序', order: 2, view: 'number', type: 'number' },
  createTime: { title: '创建时间', order: 3, view: 'datetime', type: 'string' },
  updateTime: { title: '更新时间', order: 4, view: 'datetime', type: 'string' },
  createBy: { title: '创建人', order: 5, view: 'text', type: 'string' },
  updateBy: { title: '更新人', order: 6, view: 'text', type: 'string' },
  toInformation: { title: '点击前往资讯页', order: 7, view: 'list', type: 'string', dictTable: "nurse_information", dictCode: 'code', dictText: 'title' },
};
